<template>
  <div class="GoodsListItem" @click="itemClick">
    <img v-lazy="showImage" alt="" @load="imageLoad" />
    <div>
      <p>
        {{ goodsItem.title }}
      </p>
      <span class="price">
        {{ goodsItem.price }}
      </span>
      <span class="souchang"> ✩ {{ goodsItem.cfav }} </span>
    </div>
  </div>
</template>

<script>
export default {
  name: "GoodsListItem",
  components: {},
  props: {
    goodsItem: {
      type: Object,
      default() {
        return {};
      },
    },
    isClick: {
      type: Boolean,
      default() {
        return false;
      },
    },
  },
  computed: {
    showImage() {
      return this.goodsItem.image || this.goodsItem.show.img;
    },
  },
  methods: {
    imageLoad() {
      this.$bus.$emit("itemImageLoad");
    },
    itemClick() {
      if (this.isClick) this.$router.push("./detail/" + this.goodsItem.iid)
      else 
      {
         this.$toast.show("功能还未开发", 1000);
      }
    },
  },
};
</script>

<style scoped>
.GoodsListItem {
  width: 46%;
  position: relative;
  border-radius: 7px;
  overflow: hidden;
}
.GoodsListItem img {
  width: 100%;
}
.GoodsListItem p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.GoodsListItem .price {
  color: red;
  font-size: 15px;
  text-align: left;
}
.GoodsListItem .souchang {
  position: absolute;
  right: 10px;
}
</style>